#include <string>
#include <iostream>
using namespace std;
class Solution
{
private:
public:
    string intToRoman(int num)
    {
        char sims[7] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'};

        int oneIndex = 0, fiveIndex = 1, tenIndex = 2;
        string ans = "";
        int digit;
        char one = sims[oneIndex];
        char five;
        char ten;
        while (num != 0)
        {
            one = sims[oneIndex];
            if (fiveIndex < 7 && tenIndex < 7)
            {
                five = sims[fiveIndex];
                ten = sims[tenIndex];
            }

            digit = num % 10;
            num /= 10;
            oneIndex += 2;
            fiveIndex += 2;
            tenIndex += 2;
            if (digit == 0)
            {
                continue;
            }
            switch (digit)
            {
            case 4:
                ans = five + ans;
                ans = one + ans;
                break;
            case 5:
                ans = five + ans;
                break;
            case 9:
                ans = ten + ans;
                ans = one + ans;
                break;
            default:
                string s = "";
                if (digit > 5)
                {
                    digit -= 5;
                    s += five;
                }
                while (digit > 0)
                {
                    s += one;
                    digit -= 1;
                }
                ans = s + ans;
            }
        }
        return ans;
    }
};

int main(int argc, char const *argv[])
{

    Solution s;
    for (int i = 0; i < 2000; i++)
    {
        /* code */
        cout << i << ", " << s.intToRoman(i) << endl;
    }
    return 0;
}
